package com.example.demo517.controller;
import com.example.demo517.entity.Studentinfo;
import com.example.demo517.service.Student_Info_Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.example.demo517.vo.viewStudentinfo;

import java.util.List;

@RestController
@RequestMapping("/student")
@CrossOrigin
public class Student_Info_Controller {
    @Autowired
    private Student_Info_Service student_Info_Service;
    @GetMapping("/1")
    public String getStudent(){
        System.out.println("getStudent");
        return "Student114";
    }
    @GetMapping("/abc")
    public String getStudentabc(){
        System.out.println("getStudent");
        return "Student114";
    }
    @GetMapping("/listpage")
    public PageInfo<Studentinfo> findStudentPages(Integer pageNum, Integer pageSize) {
        PageInfo<Studentinfo> pageInfo = student_Info_Service.findStudentPages(pageNum, pageSize);
        return pageInfo;
    }
    @GetMapping("/listclspage")
    public PageInfo<viewStudentinfo> findStudentInfo_clsname(Integer pageNum, Integer pageSize){
        return student_Info_Service.findStudentInfo_clsname(pageNum, pageSize);
    }
    @GetMapping("/list")
    public List<Studentinfo> getStudentList(){
        List<Studentinfo>studentinfos = student_Info_Service.getStudentInfo();
        return studentinfos;

    }
    @GetMapping("/find")
    public Studentinfo getStudentInfo(@RequestParam Integer id){
        Studentinfo studentinfo = student_Info_Service.getStudentInfoByStuid(id);
        return studentinfo;
    }
    @GetMapping("/delete")
    public int deleteStudentinfo(Integer id){
        int results =student_Info_Service.deleteStudentInfoByStuid(id);
        return results;
    }
    @PostMapping("/insert")
    public int insertStudentinfo(@RequestBody Studentinfo studentinfo ){
        int result =student_Info_Service.insertStudentInfo(studentinfo);
        return result;
    }
    @PostMapping("/update")
    public Integer updateStudentInfo(@RequestBody Studentinfo studentinfo){
        int result =student_Info_Service.updateStudentInfo(studentinfo);
        return result;
    }
}
